#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
map<ll,int> m;
ll mod = 10000007;
int main(){
    std::ios::sync_with_stdio(false);
    ll n,a,b;
    while(cin>>n){
        n--;
        while (n--){
            cin>>a>>b;
            s.insert(a);
            s.insert(b);
        }
        ll sum = 0,count=s.size();
        for (int i = 1; i <= count; ++i) {
            sum=(i%mod+sum%mod);
        }
        cout<<sum<<endl;
    }

    return 0;
}